/*
 ------------------------------------------------------------------------------
 Copyright (C) 2009-2011 Eternal Games.

 This file is part of the Eternal Tech source code.

 The Eternal Tech source code is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or (at your
 option) any later version.

 The Eternal Tech source code is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 more details.

 You should have received a copy of the GNU General Public License along with
 the Eternal Tech source code; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 ------------------------------------------------------------------------------
*/


//
// s_local.h - Local header file to all sound files
//


#if !defined(__S_LOCAL_H__) || !INCLUDE_GUARDS
#define __S_LOCAL_H__


#include "../qcommon/qcommon.h"
#include "../win32/win_qal.h"


/*
 ==============================================================================

    S_SOUND.CPP

 ==============================================================================
*/

#define SOUNDS_HASH_SIZE				512

enum soundFlags_t {
	SF_INTERNAL				= BIT(0)
};

struct sound_t {
	char					name[MAX_PATH_LENGTH];

	int						flags;
	int						rate;
	int						samples;
	int						length;
	int						size;

	int						tableSize;
	float					*tableValues;

	uint					bufferId;

	struct sound_t			*nextHash;
};

void				S_InitSounds ();
void				S_ShutdownSounds ();

/*
 ==============================================================================

    S_ALSTATE.CPP

 ==============================================================================
*/

void				S_CheckForErrors ();

/*
 ==============================================================================

    S_VOICE.CPP

 ==============================================================================
*/

#define MAX_VOICE_SAMPLES				16000

#define VOICE_RATE						8000

/*
 ==============================================================================

    S_CHANNEL.CPP

 ==============================================================================
*/

#define MAX_SOUND_CHANNELS				256

struct channel_t {
	uint					sourceId;
};

void				S_InitChannels ();
void				S_ShutdownChannels ();

/*
 ==============================================================================

    S_MAIN.CPP

 ==============================================================================
*/

struct sndGlobals_t {
	// Channels
	int						numChannels;
	channel_t				channels[MAX_SOUND_CHANNELS];

	// Memory pool
	memoryPool_t			*soundMemoryPool;

	// Internal assets
	sound_t					*defaultSound;
};

extern sndGlobals_t			snd;

extern cvar_t				*s_logFile;
extern cvar_t				*s_ignoreALErrors;

extern cvar_t				*s_playDefaultSound;
extern cvar_t				*s_soundQuality;
extern cvar_t				*s_maxChannels;


#else
FILE_WARNING
#endif   // __S_LOCAL_H__